package org.hope.lee.utils;

/**
 *   
 *  @ProjectName: separated-read-write 
 *  @Description:
 *  @author: lisen
 *  @date: 2017/12/10  
 */
public class DBContextHolder {

    private static ThreadLocal<String> contextHolder = new ThreadLocal<String>();

    public static String getDBType() {
        String db = contextHolder.get();
        if(db == null) {
            db = DBType.DB_TYPE_MASTER; //默认是master库
        }

        return db;
    }

    public static void setDBType(String dbType) {
        contextHolder.set(dbType);
    }

    public static void clearDBType() {
        contextHolder.remove();
    }

}
